package com.jfeat.am.module.wegou.services.patch.impl;

import com.jfeat.am.module.wegou.services.patch.UserIdentityPatchService;
import com.jfeat.am.module.wegou.services.persistence.dao.UserIdentityMapper;
import com.jfeat.am.module.wegou.services.persistence.model.UserIdentity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2018/1/31.
 */

/**
 * 仅用于登录的时候简单判断用户的身份（登录时用户传递 identity（PLATFORM, RESTAURANT, CANTEEN)表明他以什么身份登录）。
 * 登录成功之后，用户想进行其他操作还是要检查权限
 */
@Service
public class UserIdentityPatchServiceImpl implements UserIdentityPatchService {

    @Resource
    UserIdentityMapper userIdentityMapper;

    @Override
    public boolean isIdentity(Long userId, String identity) {
        UserIdentity userIdentity = new UserIdentity();
        userIdentity.setUserId(userId);
        userIdentity.setIdentity(identity);
        userIdentity = userIdentityMapper.selectOne(userIdentity);
        return userIdentity == null ? false : true;
    }

}
